<?php
//喜欢的


$_SESSION['code']=1;$_SESSION['id_name']='351';
$info=array();
if ($_SESSION['code']==1)
{
    $id_name=$_SESSION['id_name'];//用户的ID
    $id_wenzhang=$_SESSION['id'];
    $i=$oMysql->get("SELECT `id`,`Preferred User ID` FROM xihuan WHERE `id`=$id_wenzhang AND `Preferred User ID`='$id_name';")?true:false;   //判断是否点击过
    //$uo=$oMysql->get("SELECT `id`,`Preferred User ID` FROM xihuan WHERE `id`=$id_wenzhang OR `Preferred User ID`='$id_name';");
    if ($i==true){
        $info['or']=false;
        echo json_encode($info);
        exit;
    }
    $if='wenzhang';
    $lo=$oMysql->insert('xihuan',array('id'=>$id_wenzhang,'Favorite time'=>time(),'Preferred User ID'=>$id_name));
    if ($lo==true)
    {
        $a=$oMysql->get("SELECT lvek FROM wenzhang WHERE `id`='$id_wenzhang'");
        $u=(int)$a[0]['lvek']+=1;
        $oMysql->gai($if,array('lvek'=>"$u"),"`id`=$id_wenzhang");
        $info['or']=$u;
        echo json_encode($info);
    }
}
else
{
    $info['or']='请登入';
    echo json_encode($info);
}
